// 创建 管理员受保护的组件, (只有在登录后才能够访问该组件里的内容)
import React from 'react'
import { Route, Redirect } from 'react-router-dom'
import { isAuth } from '../../helper/auth'

function AdminPrivate({component: Component, ...rest}) {
	return (
		<Route
			{...rest}
			render={
				props => {
					if(isAuth()) return <Component {...props}/>
					return <Redirect to='/login'/>
				}
			}
		></Route>
	)
}

export default AdminPrivate
